<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$f_showextra = true;
$ui = new UI();
include( "member/news.php" );
$conf = new Config();
if ($conf->get("calcbet") == 1)
{
    $ui->showErrorPage("<p class=error>颁奖过帐中，请稍後再使用本功能！</p>");
    exit();
}
$chkArrNoGet = array(29, 39, 40, 41, 42, 43, 44, 45);
$sql = $_GET['c'];
if ($sql == "")
{
    $ui->showErrorPage("<p class=error>错误的参数！</p>");
    exit();
}
$bettype = "";
$order = 0;
$number = "";
if (isset($_GET['t']))
{
    $bettype = intval(getvar("t"));
}
if (isset($_GET['o']))
{
    $order = intval(getvar("o"));
}
if (isset($_GET['n']))
{
    $number = getvar("n");
}
$sql = "select * from " . $sql;
if ($number != "" && $number != "\"\"" && $number != "''")
{
    if ($bettype == 19)
    {
        $sql .= " numbers like '" . $number . "%'";
    }
    else if ($bettype == 27 || $bettype == 36)
    {
        if (!strpos($number, "|"))
        {
            $sql .= " numbers like '" . $number . "%'";
        }
        else
        {
            $sql .= " numbers='" . $number . "'";
        }
    }
    else if (( $bettype == 25 || $bettype == 26 ) && 0 < $order)
    {
        $sql .= " numbers='" . $order . " " . $number . "'";
    }
    else if (7 <= $bettype && $bettype <= 11 || in_array($bettype, $chkArrNoGet) || $bettype == 32 || $bettype == 33)
    {
        $p = explode(",", $number);
        if (in_array($bettype, $chkArrNoGet))
        {
            $sqlAddTemp = implode("%", $p);
            $sql .= " line_nums like '%{$sqlAddTemp}%'";
        }
        else
        {
            if ($bettype == 8 || $bettype == 9 || $bettype == 33)
            {
                $sql .= " line_nums like '%" . $p[0] . "%" . $p[1] . "%" . $p[2] . "%'";
            }
            else
            {
                $sql .= " line_nums like '%" . $p[0] . "%" . $p[1] . "%'";
            }
        }
    }
    else
    {
        $sql .= " numbers='" . $number . "'";
    }
}
$whereFlag = strpos($sql, "where");
if ($whereFlag === false)
{
    $subStrWhere = " where ";
}
else
{
    $subStrWhere = " and ";
}
$betRType = intval(getvar("betRType"));
switch ($betRType)
{
    case 1 :
        $rameSQLStr8 = " {$subStrWhere} rame = 9 AND (r5 - back) <= 0 ";
        $rameTitleStr = " 选项:上缴";
        break;
    case 2 :
        $rameSQLStr8 = " {$subStrWhere} rame = 9 AND (r5 - back) > 0 ";
        $rameTitleStr = " 选项:得分";
        break;
    default :
        $rameSQLStr8 = "";
        $rameTitleStr = " 选项:全部";
        break;
}
$sql .= " {$rameSQLStr8} order by createtime desc, bettype, numbers";
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
if ($page == 0)
{
    $page = 1;
}
$pagesize = 15;
$rst = getdb($sql, $page, $pagesize);
$movenext = !$rst->eof;
if ($movenext)
{
    $noteArr = array();
    $i = 0;
    while ($i < 10)
    {
        $noteArr[$i] = $conf->get("port_systemuser_" . $i);
        ++$i;
    }
    echo "<br>";
    echo title("公司 走飞清单 - {$rameTitleStr}", "<a href='#' onclick='window.print()'>" . L_PRINT . "</a> | <a href='javascript:history.back()'>回上一页</a>");
    echo "<br>";
    echo "<table width=800 border=1 cellpadding=3 cellspacing=0>";
    echo "<tr class=td0><td nowrap>序号 / 时间<td nowrap>期数 / 开奖日期<td nowrap>走飞内容<td nowrap>赔率<td nowrap>走飞金额<td nowrap>退水<td nowrap>结果<td nowrap>备注";
    $total = 0;
    $wintot = 0;
    $backs = 0;
    $items = 0;
    while ($movenext)
    {
        ++$items;
        echo "<tr align=right class=td2 onmouseover=msover() onmouseout=msout() valign=top>";
        echo "<td nowrap><font color=#217952>" . $rst->f['id'] . "</font> &nbsp; " . date("m-d H:i:s", $rst->f['createtime']);
        $lotto = get_lotto($rst->f['lotto_id']);
        echo "<td nowrap>" . d3($lotto->data['round']) . " 期 &nbsp; <font color=#217952>" . $lotto->data['open'] . "</font>";
        echo "<td nowrap>" . GetBetContent($rst->f['bettype'], $rst->f['numbers'], $rst->f['amount']);
        echo "<td nowrap>" . show_rate($rst->f['bettype'], $rst->f['rate'] - 0);
        echo "<td nowrap>" . $rst->f['amount'];
        echo "<td nowrap>" . $rst->f['back'] * $rst->f['amount'] / 100;
        echo "<td nowrap>" . say_numbercolor($rst->f['r5']);
        $reme = "";
        if ($rst->f['rame'] == 1)
        {
            $reme = "<font color='red'>逾时</font>";
        }
        if ($rst->f['rame'] == 2)
        {
            $reme = "<font color='red'>取消</font>";
        }
        if ($rst->f['rame'] == 3)
        {
            $reme = "<font color='red'>异常</font>";
        }
        if ($rst->f['rame'] == 4)
        {
            $reme = "<font color='red'>特连</font>";
        }
        if ($reme == "")
        {
            $total += $rst->f['amount'];
            $backs += $rst->f['back'] * $rst->f['amount'] / 100;
            $wintot += $rst->f['r5'];
            if ($rst->f['account'] != "" && isset($noteArr[$rst->f['account']]))
            {
                $reme = $noteArr[$rst->f['account']];
            }
            else
            {
                $reme = $rst->f['account'];
            }
        }
        if (chkBet_peace(array("a1" => $rst->f['r5'], "b1" => 0, "rame" => $rst->f['rame'])))
        {
            $reme .= " <font class='betpeace'>和局</font>";
        }
        echo "<td nowrap>" . $reme;
        $rst->movenext();
        $movenext = !$rst->eof;
    }
    echo "<tr class=td1><td colspan=4 align=right><b>合计 " . $items . " 笔</b>";
    echo "<td align=right nowrap><b>" . $total . "</b>";
    echo "<td align=right nowrap><b>" . $backs . "</b>";
    echo "<td align=right nowrap><b>" . say_numbercolor($wintot) . "</b><td>";
    echo "<tr><td class=td0 colspan=10>" . $rst->pagelink() . "</td></tr>";
    echo "</table>";
}
$ui->footer();
?>